package com.jsoft.model;

import com.jsoft.dto.PlaceDto;
import com.jsoft.model.core.BaseDao;

import javax.persistence.*;

/**
 * Date: 15.08.13
 * Time: 14:07
 */

@Entity
@Table(name = "places")
public class PlaceDao extends BaseDao {
    @Column(name = "name")
    private String name;
    @Column(name = "pos_x")
    private Double posX;
    @Column(name = "pos_y")
    private Double posY;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "sector_id", nullable = false)
    private SectorDao sector;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getPosX() {
        return posX;
    }

    public void setPosX(Double posX) {
        this.posX = posX;
    }

    public Double getPosY() {
        return posY;
    }

    public void setPosY(Double posY) {
        this.posY = posY;
    }

    public SectorDao getSector() {
        return sector;
    }

    public void setSector(SectorDao sector) {
        this.sector = sector;
    }

    public PlaceDto wrapPlaceDto() {
        PlaceDto dto = new PlaceDto();
        dto.setId(this.getObjectId());
        dto.setName(this.getName());
        dto.setPosX(this.getPosX());
        dto.setPosY(this.getPosY());
        return dto;
    }

    public PlaceDao wrapPlaceDao(PlaceDto dto) {
        PlaceDao dao = new PlaceDao();
        dao.setName(dto.getName());
        dao.setPosY(dto.getPosY());
        dao.setPosX(dto.getPosX());
        return dao;
    }
}
